package com.example.mvp_demo2.view.biz;

import com.example.mvp_demo2.view.bean.User;

/**
 * Created by Administrator on 2017/3/26.
 * moudle层,处理用户登录的业务
 */

public class UserBiz implements IUserBiz{

    @Override
    public void login(final String username, final String passworld, final OnLoginListener onLoginListener) {
        new Thread().start();



        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

                //模拟登录,判断帐号密码都正确时,返回登录成功的信息否则返回登录失败的信息
                if ("eye".equals(username)&&"123".equals(passworld)){
                    User user = new User();
                    user.setUsername(username);
                    user.setPassworld(passworld);

                    //点击登录时,调用登录接口监听登录状态
                    onLoginListener.loginSuccess(user);
                }else {
                    onLoginListener.loginFailed();
                }
            }
        }).start();
    }
}
